﻿namespace EFS.RC.ConversationBrowser.Controls.Browse
{
	public partial class Results : EFS.RC.ConversationBrowser.Controls.Control
	{
		#region Delegates
		/// Search
		public delegate void SearchStartedDelegate();

		/// SearchCompleted
		public delegate void SearchCompletedDelegate();
		#endregion

		public Results()
		{
			InitializeComponent();
		}

		#region Properties
		/// Property ResultsCount: Get, Set
		public System.Int32 ResultsCount
		{
			set
			{
				//labelResults.Content = System.String.Format("Results: {0}", value);
			}
		}
		#endregion

		#region Utilities
		/// Reset
		public void Reset()
		{
			ResultsCount = 0;
			dataGridResults.ItemsSource = null;
		}
		#endregion

		#region LoadData
		/// LoadData
		public void LoadData(EFS.RC.ConversationBrowser.Tools.Search.ResultList results)
		{
			ResultsCount = results.Items.Length;
			dataGridResults.ItemsSource = results.Items;
		}
		#endregion

		#region Events
		/// hyperlinkButtonOpen_Click
		private void hyperlinkButtonOpen_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			// get current
			EFS.RC.ConversationBrowser.Tools.Search.Result result = (EFS.RC.ConversationBrowser.Tools.Search.Result)dataGridResults.SelectedItem;
			if (null == result)
			{
				return;
			}

			// open
			EFS.RC.ConversationBrowser.Common.Main.ViewConversationExternal(result.ConversationGuid.Value, result.Occurred.Value);
			//EFS.RC.ConversationBrowser.Common.Main.ViewConversationExternal(System.Guid.NewGuid(), System.DateTime.Now);
		}
		#endregion
	}
}
